import {
  request
} from '../../request/index'
import regeneratorRuntime from '../../lib/runtime/runtime'
Page({

  data: {
    cats:[],
    navName:"华语",
    playList:[],
    isTriggered:false,
    navId:5001

  },

  onLoad: function (options) {
    this.getSongListTags()

    this.getSongList(this.data.navName)
  },
  //获取歌单标签
  async getSongListTags(){
    let {data} = await request({url:"/playlist/highquality/tags"})
    this.setData({
      cats:data.tags,
      navId:data.tags.id
    })
  },

  //tab切换
  handleItemTap(e) {
    let navName = e.currentTarget.dataset.name;
    let navId = e.currentTarget.id;
    this.setData({
      navName,
      navId: navId,
      playList: []
    })
    this.getSongList(navName)
  },

  //获取歌单列表
  async getSongList(navName){
    let res = await request({url:"/top/playlist/highquality",data:{cat:navName,limit:50}})
    this.setData({
      playList:res.data.playlists,
      isTriggered:false
    })
  }
})